<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <style>
    #smile {
      width: 300px;
      height: 300px;
      background: url("./erik_ce204002.jpg") no-repeat;
      background-size: cover;
    }
  </style>
  <body>
    <div id="smile"></div>
  </body>
  <script>
    var img = document.getElementById("smile");
    img.style.backgroundPositionY = "-1px";
    var flag = false;
    setInterval(move, 100);
    function move() {
      const y = parseInt(img.style.backgroundPositionY);
      if (flag) {
        if (y < -300) {
          img.style.backgroundPositionY = y + 300 + "px";
        } else {
          flag = false;
        }
      } else {
        if (y > -4800) {
          img.style.backgroundPositionY = y - 300 + "px";
        } else {
          flag = true;
        }
      }
    }
  </script>
</html>
